//
//  MapTestViewController.m
//  ConvenientlyTake
//
//  Created by 张奇 on 2023/1/10.
//

#import "MapTestViewController.h"
#import <MAMapKit/MAMapKit.h>
#import <AMapFoundationKit/AMapFoundationKit.h>
#import "CustomAnnotationView.h"
#import "TGMapView.h"
#import "TGNavMapView.h"
#import "TGPointAnnotation.h"

@interface MapTestViewController ()<MAMapViewDelegate>

@property (nonatomic, strong) MAMapView *mapView;

@end

@implementation MapTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //标记
//    MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
//    pointAnnotation.coordinate = CLLocationCoordinate2DMake(29.89, 107.7);
//    pointAnnotation.title = @"08月09日签收结束";
//    pointAnnotation.subtitle = @"郑州市";
    
    //构造折线数据对象
//    CLLocationCoordinate2D commonPolylineCoords[8];
//    commonPolylineCoords[0].latitude = 30.67;
//    commonPolylineCoords[0].longitude = 104.06;
//
//    commonPolylineCoords[1].latitude = 30.88;
//    commonPolylineCoords[1].longitude = 104.32;
//
//    commonPolylineCoords[2].latitude = 30.57;
//    commonPolylineCoords[2].longitude = 104.94;
//
//    commonPolylineCoords[3].latitude = 30.2;
//    commonPolylineCoords[3].longitude = 103.29;
//
//    commonPolylineCoords[4].latitude = 30.97;
//    commonPolylineCoords[4].longitude = 103.81;
//
//    commonPolylineCoords[5].latitude = 31.48;
//    commonPolylineCoords[5].longitude = 104.73;
//
//    commonPolylineCoords[6].latitude = 30.8;
//    commonPolylineCoords[6].longitude = 106.06;
//
//    commonPolylineCoords[7].latitude = 29.89;
//    commonPolylineCoords[7].longitude = 107.7;
 
//    TGMapView *mapView = [[TGMapView alloc] initWithFrame:CGRectMake(0, 100, SCREEN_WIDTH, 300) coordinates:commonPolylineCoords annotationCount:8 endPointAnnotation:pointAnnotation];
//    [self.view addSubview:mapView];
    
    TGPointAnnotation *pointAnnotation = [[TGPointAnnotation alloc] init];
    pointAnnotation.coordinate = CLLocationCoordinate2DMake(29.89, 107.7);
    pointAnnotation.title = @"08月09日签收";
    pointAnnotation.subtitle = @"郑州市";
    pointAnnotation.remark = @"终点";
    
    NSMutableArray *locationArray = [NSMutableArray array];
    NSArray *dataArray = @[@{@"latitude": @"30.67", @"longitude": @"104.06"},
                           @{@"latitude": @"30.88", @"longitude": @"104.32"},
                           @{@"latitude": @"30.57", @"longitude": @"104.94"},
                           @{@"latitude": @"30.2", @"longitude": @"103.29"},
                           @{@"latitude": @"30.97", @"longitude": @"103.81"},
                           @{@"latitude": @"31.48", @"longitude": @"104.73"},
                           @{@"latitude": @"30.8", @"longitude": @"106.06"},
                           @{@"latitude": @"29.89", @"longitude": @"107.7"}];
    for (int i = 0; i < dataArray.count; i++) {
        NSDictionary *data = dataArray[i];
        CGFloat latitude = [data[@"latitude"] floatValue];
        CGFloat longitude = [data[@"longitude"] floatValue];
        CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
        [locationArray addObject:location];
    }
    
    TGNavMapView  *mapView = [[TGNavMapView alloc] initWithFrame:CGRectMake(0, 100, SCREEN_WIDTH, 300) locations:locationArray endPointAnnotation:pointAnnotation];
    [self.view addSubview:mapView];
    
}

- (void)setupNavigationItems {
    [super setupNavigationItems];
    [self setNavStyleWhiteAndBackBtn];
}

@end
